package com.ruoqing.auth.test;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
		public static void main(String[] args) {
				Scanner scanner = new Scanner(System.in);
				while (scanner.hasNextLine()){
						char[] chars = scanner.nextLine().toCharArray();
						int count = 0;int length = chars.length;int middle = length >>1;
						for (char aChar : chars) {
								if (Character.isUpperCase(aChar)) count++;
						}
						if (count > middle) {
								count = count - middle;
						}else if(count==middle) {
								count = 0;
						}else{
								count = middle - count;
						}
						System.out.println(count);
				}
		}
		
		static class a{
				public static void main(String[] args) {
						Scanner scanner = new Scanner(System.in);
						int result = 0;
						while (scanner.hasNextLine()){
								int n = Integer.parseInt(scanner.nextLine());
								String[] s = scanner.nextLine().split(" ");
								Map<Integer,Integer> map = new HashMap<Integer,Integer>(n);
								for (int i = 0; i < n; i++) {
										map.put(i+1,Integer.parseInt(s[i]));
								}
								for (int i = 1; i <= n; i++) {
										int temp = 0;
										for (int j = 1; j <= n; j++) {
												if (j == 1){
														temp = map.get(i) ^ (i % j);
												}else {
														temp ^= (i % j);
												}
										}
										result ^= temp;
								}
								System.out.println(result);
						}
				}
		}
}
